{% extends '::base.html.twig' %}

{% block body -%}
    <div class="box">
    <h2 class="box_head">Editar Pais</h2>
    <div class="controls">
        <a href="#" class="grabber"></a>
        <a href="#" class="toggle"></a>
    </div>
    <div class="toggle_container">
        <div class="block">

            <form action="{{ path('Pais_update', { 'id': entity.id }) }}" method="post" {{ form_enctype(edit_form) }}>
                <div>
                    <div style="padding-left: 10px; color: red;">{{ form_errors(edit_form) }}</div>
                    <fieldset class="label_side top right">
                        <label>Nombre</label>
                        <div class="clearfix">
                            {{ form_widget(edit_form.nombre) }}
                            <span class="form-erros">
                                {{ form_errors(edit_form.nombre) }}
                            </span>
                        </div>
                    </fieldset>
                    <fieldset class="label_side top right">
                        <label>Sigla</label>
                        <div class="clearfix">
                            {{ form_widget(edit_form.sigla) }}
                            <span class="form-erros">
                                {{ form_errors(edit_form.sigla) }}
                            </span>
                        </div>
                    </fieldset>
                    {{ form_rest(edit_form) }}
                </div>
                <div class="button_bar clearfix">
                    <button type="submit" class="dark green">
                        <div class="ui-icon ui-icon-check"></div>
                        <span>Guardar</span>
                    </button>
                    <button class="dark red dialog_button" data-dialog="dialog_delete" type="button">
                        <div class="ui-icon ui-icon-trash"></div>
                        <span>Eliminar<span>
                    </button>
                    <a href="{{ path('Pais') }}">
                        <button class="dark light" type="button">
                            <div class="ui-icon ui-icon-closethick"></div>
                            <span>Cancelar</span>
                        </button>
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="display_none">
    <div id="dialog_delete" class="dialog_content narrow no_dialog_titlebar" title="Delete Confirmation">
        <div class="block">
            <div class="section" style="font-size: 14px;">
                <h1>Eliminar Pais</h1>
                <div class="dashed_line"></div>
                <p>"<strong>Atención:</strong> ¿Esta seguro que desea eliminar el Pais?"</p> 
                <p><strong style="color: red;">ESTA ACCION ES IRREVERSIBLE</strong></p>
            </div>
            <div class="button_bar clearfix">
                <form action="{{ path('Pais_delete', { 'id': entity.id }) }}" method="post" id="f-eliminar" {{ form_enctype(delete_form) }}>
                    <input type="hidden" name="_method" value="DELETE" />
                    {{ form_widget(delete_form) }}
                    <button type="submit" class="delete_confirm dark red" id="eliminar">
                        <div class="ui-icon ui-icon-check"></div>
                        <span>Eliminar</span>
                    </button>
                </form>
                <button class="light send_right close_dialog">
                    <div class="ui-icon ui-icon-closethick"></div>
                    <span>Cancelar</span>
                </button>
            </div>
        </div>
    </div>
</div>

{% if app.request.get('error') == 1%}
<div class="display_none">
    <div id="dialog_welcome" class="dialog_content no_dialog_titlebar wide" >
        <div class="block">
            <div class="section">
                <h1>Error</h1>
                <div class="dashed_line"></div>	
                <p style="font-size: 14px;">No se pudo eliminar este Pais ya que el mismo posee registros asociados.</p>
            </div>
            <div class="button_bar clearfix">
                <button class="blue close_dialog">
                    <div class="ui-icon ui-icon-check"></div>
                    <span>Aceptar</span>
                </button>
            </div>
        </div>
    </div>
</div> 
{% endif %}


{% block javascripts %}
<script type="text/javascript">
    $(document).ready(function() {       
        $('#eliminar').click(function(){
            $('#f-eliminar').submit();
        });
        
        $("#dialog_welcome").dialog("open");
    });
    </script>
{% endblock %}
{% endblock %}

